<?php
namespace wepay\join\demo\api;
require_once("WebBase.php");
//aes 加解密
class WebSecurity{

    public function encrypt($privateKey,$iv,$data){

        $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $privateKey, $data, MCRYPT_MODE_CBC, $iv);
        $base64method=new WebBase();
        return $base64method->encode($encrypted);
    }

    public function decrypt($privateKey,$iv,$data){

        $base64method=new WebBase();
        $encryptedData = $base64method->decode($data);
        $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $encryptedData, MCRYPT_MODE_CBC, $iv);
        return $decrypted;
    }
}

?>